<?php

namespace App\Services;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

class LoggerService
{
    protected $logger;

    public function __construct($channel = 'app', $logFile = 'app.log')
    {
        $logDir = __DIR__.'/../../storage/logs/';
        if (!is_dir($logDir)) {
            mkdir($logDir, 0777, true);
        }
        $this->logger = new Logger($channel);
        $this->logger->pushHandler(new StreamHandler($logDir.$logFile, Logger::DEBUG));
    }

    public function emergency($message, array $context = [])
    {
        $this->logger->emergency($message, $context);
    }

    public function alert($message, array $context = [])
    {
        $this->logger->alert($message, $context);
    }

    public function critical($message, array $context = [])
    {
        $this->logger->critical($message, $context);
    }

    public function error($message, array $context = [])
    {
        $this->logger->error($message, $context);
    }

    public function warning($message, array $context = [])
    {
        $this->logger->warning($message, $context);
    }

    public function notice($message, array $context = [])
    {
        $this->logger->notice($message, $context);
    }

    public function info($message, array $context = [])
    {
        $this->logger->info($message, $context);
    }

    public function debug($message, array $context = [])
    {
        $this->logger->debug($message, $context);
    }
}
